{%include file="header.html"%}
<style>
input {	width: 240px;}
textarea {	width: 350px;	height: 100px;}
</style>
<body>
<div class="fixed-bar">
  <div class="item-title">
    <h3>添加配送员</h3>
  </div>
</div>
<div class="fixed_bottom">
  <form method="post" action="peisong.php" enctype="multipart/form-data" id="aspnetForm" name="form1">
    <table style=" width:100%;" cellpadding="0" cellspacing="0" class="table tb-type2">
      <tbody>
       <tr>
            <td class="firtd">所属商户: </td>
              <td>
                <select name="s_id" id="" class="form-control">
                  {%foreach from=$res item=list key=k%}
                    <option {%if $list.s_id==$res1.user_shid%} selected="selected"{%/if%} value="{%$list.s_id%}">{%$list.shop_name%}</option>
                  {%/foreach%}
                </select>
            </td>
        </tr>
        <tr>
          <td class="firtd">配送员名称:</td>
          <td>
          	<input type="text" name="user_name" id='user_name' value="{%$res1.user_name%}"required>
          </td>
        </tr>
        <tr>
          <td class="style1">&nbsp;</td>
          <td>
          	<input type="hidden" name="act" value="insert">
            <input type="hidden" name="user_id" id="user_id" value="{%$res1.user_id%}">
            <a href="JavaScript:void(0);" class="btn" onclick="reset()"><span>重置</span></a>
            <a href="JavaScript:void(0);" class="btn" onclick="$('#tj').click()"><span>确认提交</span></a>
          </td>
        </tr>
      </tbody>
    </table>
    <input type="reset" id="cz" style="display: none;">
    <input type="submit" id="tj" style="display:none;">
  </form>
</div>
</body>
<script>
    // 重置方法
    function reset(){
	$('input').val('');
	$('textarea').text('');
	$('select').val('');
}
$("#user_name").blur(function(){
  var name = $("#user_name").val();
  $.post("peisong.php",{act:'name',user_name:name},function(data){
    if(data==1){
        alert('配送员不存在');
        $('input').val('');
        $('textarea').text('');
        $('select').val('');
    }
    if(data==4){
        alert('名称不能为空');
        $('input').val('');
        $('textarea').text('');
        $('select').val('');
    }
    if(data==3){
        alert('配送员已分配');
        $('input').val('');
        $('textarea').text('');
        $('select').val('');    }
  });
});
</script>
</html>